﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace Zj.CourseManage.Domain.Events
{
    /// <summary>
    /// Event handler interface
    /// </summary>
    public interface IEventHandler
    {
        /// <summary>
        /// Handle event async
        /// </summary>
        /// <typeparam name="TEvent">The type of TEvent</typeparam>
        /// <param name="event">Event object</param>
        /// <returns></returns>
        Task<bool> HandleAsync(IEvent @event,CancellationToken cancellationToken=default(CancellationToken));
            




        /// <summary>
        /// Can event handle?
        /// </summary>
        /// <typeparam name="TEvent">The type of TEvent</typeparam>
        /// <param name="event">Event object</param>
        /// <returns></returns>
        bool CanHandle(IEvent @event);
    }


    public interface IEventHandler<TEvent>:IEventHandler
        where TEvent : IEvent
    {

        Task<bool> HandleAsync(TEvent @event, CancellationToken cancellationToken = default(CancellationToken));
    }
}
